package com.syni.mdd.yhd.common.all.controller.protect.business;

/**
 * @className BmsBusinessController
 * @description TOO
 * @Author cfx
 * @DATE 2019/4/15 14:25
 * @VERSION 1.0
 **/

import com.syni.mdd.sjb.common.component.utils.common.annotations.CheckParams;
import com.syni.mdd.sjb.common.component.utils.common.utils.ParamsMap;
import com.syni.mdd.yhd.common.all.service.BmsBusinessLabelService;
import com.syni.mdd.yhd.common.all.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/businessLabel")
public class BmsBusinessLabelController {
    @Autowired
    BmsBusinessLabelService bmsBusinessLabelService;

    @PostMapping("/searchLabelByContent")
    @CheckParams(params = {"label_name","page_num","page_size"})
    public Map<String,Object> searchLabelByContent(@RequestBody ParamsMap paramsMap){
        int recommendLabelSize = 12;
        String labelName = paramsMap.get("label_name").toString();
        Integer pageNum = Integer.parseInt(paramsMap.get("page_num").toString());
        Integer pageSize = Integer.parseInt(paramsMap.get("page_size").toString());
        Integer typeId = paramsMap.getInteger("typeId");
        if(paramsMap.containsKey("recommend_label_size") && StringUtils.checkNullAndEmpty(paramsMap.get("recommend_label_size"))){
            recommendLabelSize = Integer.parseInt(paramsMap.get("recommend_label_size").toString());
        }
        return bmsBusinessLabelService.findLabelToReleaseVideo(typeId,labelName,pageNum,pageSize,recommendLabelSize);
    }

}
